package com.ijava.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ResourceUtils;


public class SystemConfig {
	private static final Logger logger = LoggerFactory.getLogger(SystemConfig.class);
	private static final Properties config = new Properties();
	static {
		try {
			File file = ResourceUtils.getFile("classpath:resource/config_zh_CN.properties");
			config.load(file.toURI().toURL().openStream());
		} catch (FileNotFoundException e) {
			logger.error("",e);
		} catch (MalformedURLException e) {
			logger.error("",e);
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
			logger.error("",e);
		}
	}
	
	public static String getProperty(String key,String defaultValue){
		return config.getProperty(key, defaultValue);
	}
	
	public static String getProperty(String key){
		return config.getProperty(key, null);
	}
	
	
	public static void main(String[] args) {
		logger.info(SystemConfig.getProperty("MENU.ID"));
	}
}
